class UserInfoModel {
  UserInfoModel({
    String? token,
    String? userId,
    String? tokenType,
    num? exp,
    num? expIn,
    String? imToken,
    num? imExpiredTime,
    LoginUserInfo? userInfo,
  }) {
    _token = token;
    _userId = userId;
    _tokenType = tokenType;
    _exp = exp;
    _expIn = expIn;
    _imToken = imToken;
    _imExpiredTime = imExpiredTime;
    _userInfo = userInfo;
  }

  UserInfoModel.fromJson(dynamic json) {
    _token = json['token'];
    _userId = json['user_id'];
    _tokenType = json['token_type'];
    _exp = json['exp'];
    _expIn = json['exp_in'];
    _imToken = json['im_token'];
    _imExpiredTime = json['im_expired_time'];
    _userInfo =
        json['user_info'] != null ? LoginUserInfo.fromJson(json['user_info']) : null;
  }

  String? _token;
  String? _userId;
  String? _tokenType;
  num? _exp;
  num? _expIn;
  String? _imToken;
  num? _imExpiredTime;
  LoginUserInfo? _userInfo;

  UserInfoModel copyWith({
    String? token,
    String? userId,
    String? tokenType,
    num? exp,
    num? expIn,
    String? imToken,
    num? imExpiredTime,
    LoginUserInfo? userInfo,
  }) =>
      UserInfoModel(
        token: token ?? _token,
        userId: userId ?? _userId,
        tokenType: tokenType ?? _tokenType,
        exp: exp ?? _exp,
        expIn: expIn ?? _expIn,
        imToken: imToken ?? _imToken,
        imExpiredTime: imExpiredTime ?? _imExpiredTime,
        userInfo: userInfo ?? _userInfo,
      );

  String get token => _token ?? "";

  String get userId => _userId ?? "";

  String? get tokenType => _tokenType;

  num? get exp => _exp;

  num? get expIn => _expIn;

  String get imToken => _imToken ?? "";

  num? get imExpiredTime => _imExpiredTime;

  LoginUserInfo? get userInfo => _userInfo;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['token'] = _token;
    map['user_id'] = _userId;
    map['token_type'] = _tokenType;
    map['exp'] = _exp;
    map['exp_in'] = _expIn;
    map['im_token'] = _imToken;
    map['im_expired_time'] = _imExpiredTime;
    if (_userInfo != null) {
      map['user_info'] = _userInfo?.toJson();
    }
    return map;
  }
}

class LoginUserInfo {
  LoginUserInfo({
    String? id,
    String? userName,
    String? userNickname,
    String? userStatus,
    String? userEmail,
    String? sex,
    String? avatar,
    String? deptId,
    String? remark,
    String? isAdmin,
    String? phoneNum,
    String? roleId,
    String? roleName,
    String? roleKey,
    String? createdAt,
    Dept? dept,
  }) {
    _id = id;
    _userName = userName;
    _userNickname = userNickname;
    _userStatus = userStatus;
    _userEmail = userEmail;
    _sex = sex;
    _avatar = avatar;
    _deptId = deptId;
    _remark = remark;
    _isAdmin = isAdmin;
    _phoneNum = phoneNum;
    _roleId = roleId;
    _roleName = roleName;
    _roleKey = roleKey;
    _createdAt = createdAt;
    _dept = dept;
  }

  LoginUserInfo.fromJson(dynamic json) {
    _id = json['id'];
    _userName = json['user_name'];
    _userNickname = json['user_nickname'];
    _userStatus = json['user_status'];
    _userEmail = json['user_email'];
    _sex = json['sex'];
    _avatar = json['avatar'];
    _deptId = json['dept_id'];
    _remark = json['remark'];
    _isAdmin = json['is_admin'];
    _phoneNum = json['phone_num'];
    _roleId = json['role_id'];
    _roleName = json['role_name'];
    _roleKey = json['role_key'];
    _createdAt = json['created_at'];
    _dept = json['dept'] != null ? Dept.fromJson(json['dept']) : null;
  }

  String? _id;
  String? _userName;
  String? _userNickname;
  String? _userStatus;
  String? _userEmail;
  String? _sex;
  String? _avatar;
  String? _deptId;
  String? _remark;
  String? _isAdmin;
  String? _phoneNum;
  String? _roleId;
  String? _roleName;
  String? _roleKey;
  String? _createdAt;
  Dept? _dept;

  LoginUserInfo copyWith({
    String? id,
    String? userName,
    String? userNickname,
    String? userStatus,
    String? userEmail,
    String? sex,
    String? avatar,
    String? deptId,
    String? remark,
    String? isAdmin,
    String? phoneNum,
    String? roleId,
    String? roleName,
    String? roleKey,
    String? createdAt,
    Dept? dept,
  }) =>
      LoginUserInfo(
        id: id ?? _id,
        userName: userName ?? _userName,
        userNickname: userNickname ?? _userNickname,
        userStatus: userStatus ?? _userStatus,
        userEmail: userEmail ?? _userEmail,
        sex: sex ?? _sex,
        avatar: avatar ?? _avatar,
        deptId: deptId ?? _deptId,
        remark: remark ?? _remark,
        isAdmin: isAdmin ?? _isAdmin,
        phoneNum: phoneNum ?? _phoneNum,
        roleId: roleId ?? _roleId,
        roleName: roleName ?? _roleName,
        roleKey: roleKey ?? _roleKey,
        createdAt: createdAt ?? _createdAt,
        dept: dept ?? _dept,
      );

  String? get id => _id;

  String? get userName => _userName;

  String? get userNickname => _userNickname;

  String? get userStatus => _userStatus;

  String? get userEmail => _userEmail;

  String? get sex => _sex;

  String? get avatar => _avatar;

  String? get deptId => _deptId;

  String? get remark => _remark;

  String? get isAdmin => _isAdmin;

  String? get phoneNum => _phoneNum;

  String? get roleId => _roleId;

  String? get roleName => _roleName;

  String? get roleKey => _roleKey;

  String? get createdAt => _createdAt;

  Dept? get dept => _dept;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    map['user_name'] = _userName;
    map['user_nickname'] = _userNickname;
    map['user_status'] = _userStatus;
    map['user_email'] = _userEmail;
    map['sex'] = _sex;
    map['avatar'] = _avatar;
    map['dept_id'] = _deptId;
    map['remark'] = _remark;
    map['is_admin'] = _isAdmin;
    map['phone_num'] = _phoneNum;
    map['role_id'] = _roleId;
    map['role_name'] = _roleName;
    map['role_key'] = _roleKey;
    map['created_at'] = _createdAt;
    if (_dept != null) {
      map['dept'] = _dept?.toJson();
    }
    return map;
  }
}

class Dept {
  Dept({
    String? deptId,
    String? parentId,
    String? deptName,
    num? orderNum,
    String? leader,
    String? phone,
    String? email,
    String? createdAt,
    String? status,
  }) {
    _deptId = deptId;
    _parentId = parentId;
    _deptName = deptName;
    _orderNum = orderNum;
    _leader = leader;
    _phone = phone;
    _email = email;
    _createdAt = createdAt;
    _status = status;
  }

  Dept.fromJson(dynamic json) {
    _deptId = json['dept_id'];
    _parentId = json['parent_id'];
    _deptName = json['dept_name'];
    _orderNum = json['order_num'];
    _leader = json['leader'];
    _phone = json['phone'];
    _email = json['email'];
    _createdAt = json['created_at'];
    _status = json['status'];
  }

  String? _deptId;
  String? _parentId;
  String? _deptName;
  num? _orderNum;
  String? _leader;
  String? _phone;
  String? _email;
  String? _createdAt;
  String? _status;

  Dept copyWith({
    String? deptId,
    String? parentId,
    String? deptName,
    num? orderNum,
    String? leader,
    String? phone,
    String? email,
    String? createdAt,
    String? status,
  }) =>
      Dept(
        deptId: deptId ?? _deptId,
        parentId: parentId ?? _parentId,
        deptName: deptName ?? _deptName,
        orderNum: orderNum ?? _orderNum,
        leader: leader ?? _leader,
        phone: phone ?? _phone,
        email: email ?? _email,
        createdAt: createdAt ?? _createdAt,
        status: status ?? _status,
      );

  String? get deptId => _deptId;

  String? get parentId => _parentId;

  String? get deptName => _deptName;

  num? get orderNum => _orderNum;

  String? get leader => _leader;

  String? get phone => _phone;

  String? get email => _email;

  String? get createdAt => _createdAt;

  String? get status => _status;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['dept_id'] = _deptId;
    map['parent_id'] = _parentId;
    map['dept_name'] = _deptName;
    map['order_num'] = _orderNum;
    map['leader'] = _leader;
    map['phone'] = _phone;
    map['email'] = _email;
    map['created_at'] = _createdAt;
    map['status'] = _status;
    return map;
  }
}
